package cn.org.itool.ws.framework.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.StringJoiner;

/**
 * Netty配置属性
 *
 */
@Data
@Component
public class NettyProperties {

    /**
     * 服务器侦探端口
     */
    @Value("${i-tool.ws.port:3010}")
    private int port = 3010;

    /**
     * netty处理线程数
     */
    @Value("${i-tool.ws.nettyThread:2}")
    private int nettyThread = 2;

    /**
     * 处理业务的核心线程数
     */
    @Value("${i-tool.ws.serviceCoreThreads:10}")
    private int serviceCoreThreads = 10;

    /**
     * 处理业务任务的队列最大长度
     */
    @Value("${i-tool.ws.serviceQueueCapacity:500}")
    private int serviceQueueCapacity = 500;

    /**
     * 没有接收到消息开始心跳时间
     */
    @Value("${i-tool.ws.idleSec:60}")
    private int idleSec = 60;

    /**
     * 没有接收到消息关闭连接时间
     */
    @Value("${i-tool.ws.idlCloseSec:900}")
    private int idlCloseSec = 900;

    @Value("${i-tool.ws.path:/ws}")
    private String path = "/ws";

    /**
     * 心跳包时间: 单位秒
     */
    @Value("${i-tool.ws.heartbeat:2}")
    private Integer heartbeat = 2;

    /**
     * http 检测 地址
     */
    @Value("${i-tool.ws.httpHeartbeatPath:/}")
    private String httpHeartbeatPath = "/";

    @Override
    public String toString() {
        return new StringJoiner(", ", NettyProperties.class.getSimpleName() + "[", "]")
                .add("port=" + port)
                .add("nettyThread=" + nettyThread)
                .add("serviceCoreThreads=" + serviceCoreThreads)
                .add("serviceQueueCapacity=" + serviceQueueCapacity)
                .add("idleSec=" + idleSec)
                .add("idlCloseSec=" + idlCloseSec)
                .toString();
    }
}
